package cn.sylinx.horm.example.section5;

import java.util.Map;

import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.Profile;
import org.springframework.stereotype.Component;

import cn.sylinx.horm.example.section4.QueryResultDTO;
import cn.sylinx.horm.util.ParamMapBuilder;

@Profile("section5")
@Component
public class Section5 implements CommandLineRunner {

    private MyExampleCommand myExampleCommand;

    public Section5(MyExampleCommand myExampleCommand) {
        this.myExampleCommand = myExampleCommand; // 直接注入Command对象
    }

    @Override
    public void run(String... args) throws Exception {
        testCommand(true);
    }

    void testCommand(boolean useInc) {
        Map<String, Object> params = new ParamMapBuilder().put("id", 2L).put("useInc", useInc)
                .put("plsholder", "plsholder").build(); // 参数
        QueryResultDTO result = myExampleCommand.queryFist(params);
        System.out.println("result -> " + result);
        
        QueryResultDTO result1 = myExampleCommand.queryFist(2L, useInc, "plsholder1");
        System.out.println("result1 -> " + result1);
        
        QueryResultDTO result2 = myExampleCommand.queryFist(2L, useInc, "plsholder2");
        System.out.println("result2 -> " + result2);
    }
}
